package com.example.uploadpic.demo.controller;


import com.example.uploadpic.demo.bean.ResultBean;
import com.example.uploadpic.demo.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
public class PicController {
    @Autowired
    FileService fileService;
    @PostMapping("/upload")
    public ResultBean upload(@RequestParam("media")MultipartFile file){
        String filePath=fileService.saveFile(file);
        return ResultBean.success(filePath);
    }
}
